<template>
    <div class="myBox" @click="onProfile">
        <div class="L"><img :src="userInfo.avatar_cdn" /></div>
        <div class="C">
            <div class="tit" v-if="userInfo.nickname">{{ userInfo.nickname }}</div>
            <div class="tit" v-else>未设置昵称</div>
            <div class="sub">{{ userInfo.mobile_text }}</div>
        </div>
        <div class="R"><img src="/assets/images/go.png" /></div>
    </div>
    <div class="clear"></div>
    <div class="allkbox"></div>
    <div class="myboxcon" @click="onProfile">
        <p>基本资料</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" v-if="!userInfo.auth" @click="router.push('/business/base/email')">
        <p>邮箱认证</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="onColl">
        <p>我的收藏列表</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="router.push('/business/address/index')">
        <p>我的收货地址</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="router.push('/order/order/index')">
        <p>我的订单</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="router.push('/order/order/consume')">
        <p>消费记录</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="router.push('/business/base/recharge')">
        <p>充值记录</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="logOut">
        <p>注销</p>
        <img src="/assets/images/go.png">
    </div>

    <div class="clear"></div>
    <div class="h54"></div>
    <div class="clear"></div>

    <Tab />
</template>

<script setup>
import Tab from '@/components/common/Tab.vue'
import { useRouter } from 'vue-router';
import { useUserStore } from '@/store/user.js'
import { storeToRefs } from 'pinia'
import { showConfirmDialog, showToast } from 'vant'

const router = useRouter()
const userStore = useUserStore()
let { userInfo } = storeToRefs(userStore)
//跳转个人信息修改界面
function onProfile() {
    router.push('/business/base/profile')
}
//跳转我的收藏列表
const onColl = ()=>router.push('/business/base/collection')


//注销
function logOut() {
    showConfirmDialog({
        // title: '注销',
        message: '确定注销吗？',
    })
        .then(() => {
            // on confirm
            userStore.$patch((state) => {
                state.userInfo = {}
            })
            localStorage.removeItem('userInfo')
            showToast({
                message: '退出成功',
                position: 'bottom',
            });
            router.push('/business/base/login')
        })
        .catch(() => {
            // on cancel
        });
}
</script>

<style lang="scss" scoped></style>